package com.landinfo.web.rest;

import com.alibaba.fastjson.JSON;
import com.codahale.metrics.annotation.Timed;
import com.landinfo.domain.CameraInfo;
import com.landinfo.service.CameraInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * REST controller for managing DataType.
 */
@RestController
@RequestMapping("/api/camerainfo")
public class CameraInfoResource {

    private final Logger log = LoggerFactory.getLogger(CameraInfoResource.class);

    private static final String ENTITY_NAME = "cameraInfo";

    private final CameraInfoService cameraInfoService;

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    //SimpleDateFormat minSdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");


    public CameraInfoResource(CameraInfoService cameraInfoService) {
        this.cameraInfoService = cameraInfoService;
    }


    @GetMapping("/getAll")
    @Timed
    public String getAll() {
        List<CameraInfo> result = this.cameraInfoService.findAll();
//        for (int i = 0; i < result.size(); i++) {
//            if (result.get(i).getPhotoTypes() != null && result.get(i).getPhotoTypes().size() > 0) {
//                String abc = result.get(i).getPhotoTypes().size() + "";
//            }
//        }
        return JSON.toJSONString(result);
    }


}
